function [sfile, df, block] = block_info(varargin)
% get the block information for the input
% two calling modes:
% 1. two arguments: filename and wblock... the original
% 2. a single argument (sf - file selector into control)
% Last Changed 9/8/04 P. Manis
%
global CONTROL DFILE
sfile=[];
df=[];

if(nargin == 1) % just get from 'sf'
    %dfile = datac('getdfile'); % read the local current dfile for data in memory
    sflag = varargin{1};
    [dfile, DPAR2, err] = ana_setup(DFILE, sflag);
    if(sflag <= 0 | sflag > length(CONTROL)) % handle bad calling argument
        QueMessage('block_info: sflag not set in call', 1);
        return;
    end;
    filename = slash4OS([CONTROL(sflag).path '\' CONTROL(sflag).filename]); % make filename
    wblk = dfile.dblock;
else
    filename = slash4OS(varargin{1});
    wblk = varargin{2};
end;
[p f e] = fileparts(filename); % deconstruct filename
if(~strmatch(e, '.mat', 'exact')) % if its a matlab file, use different routine to parse through here
    return;
end;

sfc = sprintf('sf%d', wblk);
sd = whos('-file', filename);
sfile = load(filename, sfc); % read the stim block
if(~isempty(fieldnames(sfile)))
    sfile = eval(['sfile.' sfc]);
    dfc = sprintf('df%d', wblk);
    df = load(filename, dfc); % read the data block
    df = eval(['df.' dfc]);
else
    sfile = [];
    df = [];
end;
block = wblk;

return;
